package com.xumt.hwHMSdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;

import com.xumt.hwHMSdemo.cannectSb.HttpRequest;

public class Login3 extends AppCompatActivity {

    private String result;
    private String result1;
    private String sex=null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login3);

        Button button=(Button)findViewById(R.id.submit);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TextView textView1 = findViewById(R.id.phonenumber);
                TextView textView2 = findViewById(R.id.Email);
                RadioButton radioButton = (RadioButton) findViewById(R.id.man);
                Intent intent=new Intent(Login3.this,Login2.class);
                String phone=textView1.getText().toString();
                String Email=textView2.getText().toString();
                if (radioButton.isChecked())
                {
                    sex="man";
                }
                else {
                    sex="women";
                }


                HttpRequest request = new HttpRequest();
                new Thread() {

                    public void run() {
                        try {

                            result = request.sendGet("http://169.254.132.31:8081/user/huaweiuser", "username=" + Login2.displayname +"&"+"openID="+Login2.openID);
                            result1 = request.sendGet("http://169.254.132.31:8081/user/huaweiuserms", "name=" + Login2.displayname +"&"+"username="+Login2.displayname+"&"+
                                    "phonenumber="+phone+"&"+"Email="+Email+"&"+"sex="+sex);

                            //   System.out.println(request.sendGet("http://169.254.67.221:8080/user/login", "username=wang&password=123"));

                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }.start();

                Toast.makeText(Login3.this, "SET SUCCESS,Please login again", Toast.LENGTH_SHORT).show();
                startActivity(intent);


            }
        });

    }
}